//
//  PersonalDetailviewControllerViewController.m
//  nmrsc
//
//  Created by xumckay on 16/1/12.
//  Copyright © 2016年 bric. All rights reserved.
//

#import "PersonalDetailviewController.h"
#import "avatarCell.h"
#import "UserDetailCell.h"

@interface PersonalDetailviewController ()

@property (strong,nonatomic)UITableView *tableView;
@property (strong,nonatomic)NSArray *dataArr;
@end

@implementation PersonalDetailviewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor=[UIColor whiteColor];
    
    UIButton *backBtn=[[UIButton alloc]initWithFrame:CGRectMake(0,0,8.5,15)];
    [backBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(backClicked) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:backBtn];
    NAVBAR(@"个人资料");
    
    _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0,64,kDeviceWidth,kDeviceHeight-49)];
    _tableView.tableFooterView=[[UIView alloc]init];
    _tableView.backgroundColor=COLOR(250, 250, 250, 250);
    _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    _tableView.delegate=self;
    _tableView.dataSource=self;
    [self.view addSubview:_tableView];
    _dataArr=@[@"头像",@"用户名",@"昵称",@"性别",@"收货地址"];
}

-(void)backClicked
{
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark   ---UITableViewDelegate

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier1=@"avatarCell";
    static NSString *identifier2=@"otherKindCell";
    
    if (indexPath.row==0) {
        avatarCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier1];
        if (!cell) {
            cell=[[avatarCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier1];
        }
        cell.titleLabel.text=[_dataArr objectAtIndex:indexPath.row];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        return cell;
    }
    else
    {
        UserDetailCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier2];
        if (!cell) {
            cell=[[UserDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier2];
        }
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        cell.titleLabel.text=[_dataArr objectAtIndex:indexPath.row];
        if (indexPath.row==4) {
            cell.arrowView.hidden=NO;
            cell.detailLabel.hidden=YES;
        }
        else
        {
            cell.arrowView.hidden=YES;
            cell.detailLabel.hidden=NO;
        }
        return cell;
    }
        
    return nil;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==0) {
                                 //修改头像照片
        
    }
    else if (indexPath.row==1)
    {
        
    }
    else if (indexPath.row==2)   //修改昵称
    {
        return;
    }
    else if (indexPath.row==3)
    {
                                 //修改性别
    }
    else if (indexPath.row==4)
    {                            //收货地址
        
    }
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==0) {
        return 90;
    }
    else
    {
        return 45;
    }
}


@end
